import { sys } from "cc";
import { RankData } from "../const/enumConst";
import { GlobalFuncHelper } from "../utils/globalFuncHelper";
import { App } from "./app";
import { SingletonClass } from "./singletonClass";

/**
 * 用户管理
 */
export class UserInfo extends SingletonClass<UserInfo> implements UserInfo {
  /** 排行数据 */
  public rankData: RankData = {
    star: 0,
    id: 0,
    level: 0,
    icon: GlobalFuncHelper.getIcon(),
    name: "",
    gold: 0,
    rank: 0,
    time: "",
  }

  public pid: number = 0;

  public updateRankData(data: RankData) {
    this.rankData = data;
  }

  init(...args: any[]): void {
    this.rankData.name = "Happy Barry";
    // App.event.on(Router.rut_login, this.evtLogin, this)
  }

  evtLogin(data) {
    this.pid = data.msg.user.pid;
  }
}